package com.flashmoment.video.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: ElasticsearchConfig
 * @Author xulu
 * @Package com.flashmoment.video.config
 * @Date 2023/10/29 12:14
 */
@Configuration
public class ElasticsearchConfig {

    /**
     * 创建RestHighLevelClient对象交给Spring管理
     * @return
     */

    @Bean
    public RestHighLevelClient getClient(){
        //通过RestHighLevelClient连接elasticsearch
        //我这里使用的虚拟机安装的Elasticsearch，所以是虚拟机的ip地址
        RestHighLevelClient restHighLevelClient=new RestHighLevelClient(RestClient.builder(new HttpHost
                ("119.3.166.164",9200,"http")));
        //返回
        return restHighLevelClient;



    }

}
